//
//  LoginView.m
//  UI豆瓣
//
//  Created by dllo on 15/10/26.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "LoginView.h"
#import "RegisterViewController.h"
@implementation LoginView

- (void)dealloc
{
    [_nameTextField release];
    [_passwordTextField release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createLogin];
    }
    return self;
}

- (void)createLogin{
    
    NSMutableArray *labelArr = [NSMutableArray arrayWithObjects:@"用户名:", @"密码:", nil];
    for (int i = 0; i < labelArr.count; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 50 + i * 50, 70, 40)];
        label.text = [labelArr objectAtIndex:i];
        label.font = [UIFont systemFontOfSize:20];
        [self addSubview:label];
        [label release];
    }
    
    self.nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(120, 50, 220, 40)];
    self.nameTextField.borderStyle = UITextBorderStyleRoundedRect;
    self.nameTextField.placeholder = @"请输入用户名";
    [self addSubview:self.nameTextField];
    [_nameTextField release];
    
    self.passwordTextField = [[UITextField alloc] initWithFrame:CGRectMake(120, 100, 220, 40)];
    self.passwordTextField.borderStyle = UITextBorderStyleRoundedRect;
    self.passwordTextField.placeholder = @"请输入密码";
    self.passwordTextField.secureTextEntry = YES;
    [self addSubview:self.passwordTextField];
    [_passwordTextField release];
    
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    loginBtn.backgroundColor = [UIColor colorWithRed:0.122 green:1.000 blue:0.126 alpha:1.000];
    [loginBtn addTarget:self action:@selector(loginAction:) forControlEvents:UIControlEventTouchUpInside];
    loginBtn.frame = CGRectMake(30, 180, 150, 50);
    [loginBtn setTitle:@"登陆" forState:UIControlStateNormal];
    [self addSubview:loginBtn];
    
    UIButton *regBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    regBtn.backgroundColor = [UIColor colorWithRed:1.000 green:0.707 blue:0.106 alpha:1.000];
    [regBtn addTarget:self action:@selector(regAction:) forControlEvents:UIControlEventTouchUpInside];
    regBtn.frame = CGRectMake(200, 180, 150, 50);
    [regBtn setTitle:@"注册" forState:UIControlStateNormal];
    [self addSubview:regBtn];
    
}
//登陆按钮
- (void)loginAction:(UIButton *)loginBtn{
    [self.loginDele decideNameandPass];
}

//注册按钮
- (void)regAction:(UIButton *)regBtn{
    [self.loginDele pushToRegister];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
